'use strict';

angular.module('hackathonApp')
  .controller('NavCtrl', function ($scope, $location) {
        
        var open = true,
            sidebar = $('#sidebar-wrapper'),
            mainContain = $('#main-container'),
            contain = $('.container'),
            ctrlNav = $('#ctrlNav');

        $scope.callNav = function() {

                sidebar.css({'width': '250'});
                ctrlNav.css({'display': 'none'});
                mainContain.css({'margin-left': '250px'});
                contain.css({'width': '700px'});
                $('input').blur();

        }

        $scope.closeNav = function() {
            sidebar.css({'width': '0'});
            ctrlNav.css({'display': 'block'});
            mainContain.css({'margin-left': '0px'});
            contain.css({'width': '800px'});
        }
        
        $scope.smoothGlider = function() {

            if(open){
                sidebar.css({'width': '0'});
                ctrlNav.css({'display': 'block'});
                mainContain.css({'margin-left': '0px'});
                contain.css({'width': '800px'});
                open = false;
            } else {
                sidebar.css({'width': '250'});
                ctrlNav.css({'display': 'none'});
                mainContain.css({'margin-left': '250px'});
                contain.css({'width': '700px'});
                open = true;
            }
        }

        $scope.isActive = function (path) {
            var cur_path = $location.path().substr(0, path.length);
            if (cur_path == path) {
                if($location.path().substr(0).length > 1 && path.length == 1 ) {
                    return false;
                } else {
                    $scope.currentSection = $location.path();
                    return true;
                }
            } else {
                return false;
            }
        };
  });
